package com.xiyou.weblog.web.service.Impl;

import com.xiyou.weblog.common.domain.dos.BlogSettingsDo;
import com.xiyou.weblog.common.domain.mapper.BlogSettingsMapper;
import com.xiyou.weblog.common.utils.Response;
import com.xiyou.weblog.web.model.vo.blogsettings.FindBlogSettingsDetailRspVO;
import com.xiyou.weblog.web.service.BlogSettingsService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author xiyou
 * @description 首页博客设置模块
 */
@Service
@Slf4j
public class BlogSettingsServiceImpl implements BlogSettingsService {

    @Resource
    private BlogSettingsMapper blogSettingsMapper;


    /**
     * 获取博客设置信息
     */
    @Override
    public Response findDetail() {
        // 查询博客设置信息，默认id为1
        BlogSettingsDo blogSettingsDo = blogSettingsMapper.selectById(1L);

        // DO转 VO
        FindBlogSettingsDetailRspVO vos = FindBlogSettingsDetailRspVO.builder()
                .author(blogSettingsDo.getAuthor())
                .logo(blogSettingsDo.getLogo())
                .avatar(blogSettingsDo.getAvatar())
                .csdnHomepage(blogSettingsDo.getCsdnHomepage())
                .giteeHomepage(blogSettingsDo.getGiteeHomepage())
                .githubHomepage(blogSettingsDo.getGithubHomepage())
                .introduction(blogSettingsDo.getIntroduction())
                .name(blogSettingsDo.getName())
                .zhihuHomepage(blogSettingsDo.getZhihuHomepage())
                .build();
        return Response.success(vos);
    }
}
